﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TestPlanWordWriter.Common.Word
{
    public class StyleNameFormatter
    {
        public static string ConvertVSTONameToOpenName(string _planStyleName)
        {
            if (!string.IsNullOrEmpty(_planStyleName))
            {
                var resultArray = _planStyleName.ToCharArray().Where(x => IsValidChar(x));
                return new string(resultArray.ToArray());
            }
            else
            {
                return null;
            }
        }

        private static bool IsValidChar(char x)
        {
            if (x >= 'A' && x <= 'z')
            {
                return true;
            }
            else if (char.IsDigit(x))
            {
                return true;
            }
            else if (x == '-')
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
